import os.path

import pygame

from locals import *
import objects

class RecessedWall(objects.StaticObject):
	graphic = "recessed_wall.png"
	triggered = False
	
	def draw(self, surface):	
		surface.blit(self.graphic.subsurface(self.triggered * 32, 0, 32, 32), self._draw_position())
		
	def passable(self, object):
		return not self.triggered
		
	def stand(self, stander):
		self.triggered = True
		self.type = "wall"

class ToggleWall(objects.StaticObject):
	graphic = "toggle_wall.png"
	
	type = "toggle wall"
	
	def __init__(self, map, position, open):
		super(ToggleWall, self).__init__(map, position)
		
		self.open = open
	
	def save(self, variables):
		for key, value in variables["states"].iteritems():
			if value == self.open:
				state = key
		
		return "%s, %s" % (super(ToggleWall, self).save(variables), state)
	
	def draw(self, surface):	
		surface.blit(self.graphic.subsurface(self.open * 32, 0, 32, 32), self._draw_position())

	def passable(self, object):
		return self.open
		
class Dirt(objects.StaticObject):
	graphic = "dirt.png"
	dug = False
	
	_passable = False
	
	def draw(self, surface):	
		if not self.dug:
			super(Dirt, self).draw(surface)
			
	def passable(self, object):
		return self.dug
			
	def push(self, pusher, movement, speed):
		self.dug = True
